<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="function.jsp"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看医院</title>
    <link  href="../../hos_manage/images/favicon.ico" rel="shortcut icon" type="image/x-icon">
    <link rel="stylesheet" href="../css/messages_doctor_mes.css">
    <link rel="stylesheet" href="../css/sweetalert.css" >
    <link rel="stylesheet" href="../css/pageCode.css" />

    <link rel="stylesheet" type="text/css" href="/css/project/main.css"/>
    <link rel="stylesheet" href="/css/basic/basic.css">
    <!--[if lte IE 9]>
        <link rel="stylesheet" href="/css/basic/ie_basic.css">
    <![endif]-->
    <%-- <link rel="stylesheet" href="/css/project/user.css"> --%>
    <link rel="stylesheet" href="../css/public.css">
    <link rel="stylesheet" href="/css/privilege/add_hospital.css">

    <script src="../js/jquery-1.9.1.min.js"></script>
</head>
<body>
    <%@ include file="../header.jsp"%>
    <!--内容-->
    <div class="containerone">
    <%@ include file="../left_menu.jsp"%>
        <!--右边内容-->
        <div class="right_cont">
        <!--右边导航下面内容-->
            <div class="message_hos_news_container" id="add_hospital">
                <div class="content">
        			<div class="add-hospital-head strong">
                        <span class="js_back" @click="back()">返回</span>
        				<span class="middle">查看医院</span>
                        <watch></watch>
        				<div class="tag">
        					<tag></tag>
        				</div>
        			</div>
        			<div class="add-hospital-body">
                        <div class="add-hospital-row">
        					<span class='strong name'>医院编号</span>
                            <div class="see-hospital-input" v-html="data.hospital"></div>
        				</div>
        				<div class="add-hospital-row">
        					<span class='strong name'>医院名称</span>
                            <div class="see-hospital-input" v-html="data.name"></div>
        				</div>
                        <div class="add-hospital-row">
        					<span class='strong name'>医院描述</span>
                            <div class="see-hospital-input" v-html="data.descr"></div>
        				</div>
                        <div class="add-hospital-row">
        					<span class='strong name'>医院别名</span>
                            <div class="see-hospital-input" v-html="data.alias"></div>
        				</div>
                        <div class="add-hospital-row">
        					<span class='strong name middle'>医院类型</span>
                            <div class="see-hospital-input" v-if="data.type == 1">一级</div>
                            <div class="see-hospital-input" v-else>二级</div>
        				</div>
                        <div class="add-hospital-row" v-if="type == '2'">
                            <span class='strong name middle'>上级医院</span>
                            <div class="see-hospital-input" v-html="data.parent"></div>
        				</div>
                        <div class="add-hospital-row" v-if="type == '2'">
        					<span class='strong name'>所在城市</span>
                            <div class="see-hospital-input" v-html="data.city"></div>
        				</div>
                        <div class="add-hospital-row">
        					<span class='strong name middle'>额外信息</span>
                            <input class="add_hospital-radio middle" :class="{'add-hospital-input-checked': jsonType == '1'}" type="radio" v-model="jsonType" value="1">
                            <span class="middle">键值对</span>
                            <input class="add_hospital-radio middle" :class="{'add-hospital-input-checked': jsonType == '2'}" type="radio" v-model="jsonType" value="2">
                            <span class="middle">源码</span>
        				</div>
                        <div class="add-hospital-row">
                            <div class="key-value-container" v-show="jsonType == '1'">
                                <div class="" v-for="each in arry">
                                    key: <div class="see-hospital-input" v-html="each[0]"></div>
                                    value: <div class="see-hospital-input" v-html="each[1]"></div>
                                </div>
                            </div>
                            <div class="code-container" v-else>
                                <textarea name="name" rows="8" cols="80" v-model="json" disabled>
                                </textarea>
                            </div>
                        </div>
        			</div>
                    <%
                        if (checkAuth("编辑医院信息", input)) {
                    %>
                    <div class="submit" @click="edit()">编辑</div>
                    <%
                        }
                    %>
        		</div>
            </div>
        </div>
    </div>
    <script src="/js/sweetalert-dev.js"></script>
    <%@ include file="/svg/watch.jsp"%>
    <%@ include file="/svg/necessary.jsp"%>
    <%@ include file="/svg/tag_svg.jsp"%>
    <script type="text/javascript">
        new Vue({
            el: "#add_hospital",
            data: {
                data: {},
                arry: [],
                hospital_id: "",
                json: "",
                jsonType: '1',
            },
            methods: {
                back: function() {
                    locationHerf("hospitals");
                },
                edit: function() {
                    locationHerf("edit_hospital", {
                        data: {
                            hospital_id: this.hospital_id
                        },
                    });
                    event.stopPropagation();
                },
                jsonToArry: function(json) {
                    if (json == "") {
                        return [];
                    }
                    try {
                        var map = JSON.parse(json);
                    } catch(e) {
                        return;
                    }
                    var arr = [];
                    for (var i in map) {
                        arr.push([
                            i,
                            map[i]
                        ])
                    }
                    return arr;
                },
                arryToJson: function(arry) {
                    if (!arry) {
                        return;
                    }
                    var map = {};
                    arry.forEach(function(item) {
                        map[item[0]] = item[1];
                    });
                    return JSON.stringify(map);
                },
            },
            ready: function() {
                var seeHospital = getHrefParms("see_hospital").data;
                this.hospital_id = seeHospital.hospital_id;
                var self = this;
                $.ajax({
                    type: 'POST',
                    url: "see_hospital.jsp",
                    data: {
                        act: "show_hospital_detail",
                        hospital_id: seeHospital.hospital_id + "",
                    },
                    success: function(res) {
                        res = JSON.parse(res);
                        if (res.errcode == 0) {
                            self.data = res.data;
                            self.arry = self.jsonToArry(JSON.stringify(res.data.json));
                            self.json = JSON.stringify(res.data.json);
                        } else {
                            swal(res.errmsg);
                        }
                    },
                });
            },
            components: {
                watch: {template: "#watch"},
                tag: {template: "#tag"},
                necessary: {template: "#necessary"},
            }
        });
    </script>
</body>
</html>
